<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0,
           maximum-scale=1.0, minimum-scale=1.0"/>
    <title>angular练习--controller</title>

</head>
<body>
    <div ng-app="myApp">
        <!--<p>在输入框中的输入：</p>-->
        <!--<p>姓名：<input type="text" ng-model="name"/></p>-->

        <!--<div ng-controller="fristController">-->
            <!--{{first}}-->
            <!--{{last}}-->
        <!--</div>-->

        <!--或者-->

        <div ng-controller="fristController">
            <p>在输入框中的输入：</p>
            <p>姓名：<input type="text" ng-model="first"/></p>
            {{first}}
            {{last}}
        </div>

        <div ng-controller="secondController">
            {{person[0].name}}{{person[0].age}}
            <!--循环取数组中的数据-->
            <ul>
                <li ng-repeat="p in person">
                    {{p.name}} 年龄:{{p.age}}
                </li>
            </ul>
        </div>

    </div>
</body>
<script src="js/angular.js"></script>
<script type="text/javascript">
    // 获取angular对象通过对象，操作controller
    var app= angular.module("myApp",[]);
    app.controller('fristController', function ($scope) {
        //此处复制的对象，在绑定的对象中可以获取
        $scope.first="aa";
        $scope.last="ab";
    })

    app.controller('secondController', function ($scope) {
        $scope.person=[{name:'zhang',age:25},
            {name:'li',age:24},
            {name:'liu',age:23},
            {name:'wang',age:25}];
    })
</script>
</html>